package dao;

import java.sql.*;
import java.util.*;
import entity.Profile;

public class ExpoDao extends BaseDao {

	public List<Profile> getAllPro() {
		List<Profile> list = new ArrayList<Profile>();
		Connection conn = super.getConn();
		PreparedStatement ps = null;
		ResultSet rs = null;

		try {
			String sql = "select * from pav_profile";
			ps = conn.prepareStatement(sql);
			rs = ps.executeQuery();
			while (rs.next()) {
				Profile pf = new Profile();
				pf.setId(rs.getInt("id"));
				pf.setPav_name(rs.getString("pav_name"));
				pf.setPav_theme(rs.getString("pav_theme"));
				pf.setPav_week(rs.getString("pav_week"));
				pf.setPav_zone(rs.getString("pav_zone"));
				list.add(pf);
			}
		} catch (Exception e) {
			// TODO: handle exception
		} finally {
			super.closeAll(conn, ps, rs);
		}
		return list;
	}
	
	public int deleteById(int id)
	{
		int row = 0;
		Connection conn = super.getConn();
		PreparedStatement ps = null;
		String sql = "delete from pav_profile where id = ?";
		
		try {
			ps = conn.prepareStatement(sql);
			ps.setInt(1, id);
			row = ps.executeUpdate();
		} catch (Exception e) {
			// TODO: handle exception
		} finally {
			super.closeAll(conn, ps, null);
		}
		return row;
		
	}
}
